package org.example;

import redis.clients.jedis.Jedis;

import java.util.Random;

public class Main {
    public static void main(String[] args) {
        // 连接到本地 Redis 服务
        Jedis jedis = new Jedis("localhost", 6379);
        //缓存原来的失效时间
        int exTime = 10 * 60;
        //随机数生成
        Random randow = new Random();
        jedis.setex("myKey", exTime+ randow.nextInt(1000), "Hello, Redis!");
        // 关闭连接
        jedis.close();
    }
}